package fitbook.main;

import android.app.Activity;
import android.app.TabActivity;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class Login extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// load up the layout
		setContentView(R.layout.login);
		// ImageView image = (ImageView) findViewById(R.id.logo_image);
		// get the button resource in the xml file and assign it to a local
		// variable of type Button
		Button launch = (Button) findViewById(R.id.login_button);

		// this is the action listener
		launch.setOnClickListener(new OnClickListener() {

			public void onClick(View viewParam) {
				// this gets the resources in the xml file and assigns it to a
				// local variable of type EditText
				EditText usernameEditText = (EditText) findViewById(R.id.txt_username);
				EditText passwordEditText = (EditText) findViewById(R.id.txt_password);

				// the getText() gets the current value of the text box
				// the toString() converts the value to String data type
				// then assigns it to a variable of type String
				String sUserName = usernameEditText.getText().toString();
				String sPassword = passwordEditText.getText().toString();
				// The strings are supposed to be stored in the database..but
				// not anymore..

				if (sUserName.equals("") || sPassword.equals("")) {
					Toast msg = Toast.makeText(Login.this,
							"Please Enter Your Username/ Password",
							Toast.LENGTH_LONG);
					msg.setGravity(Gravity.CENTER, msg.getXOffset() / 2,
							msg.getYOffset() / 2);
					msg.show();

				} else {
					setContentView(R.layout.lobby);
				}
			}
		});
	}
}